home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / coreaids.zip / ATRB_WRT.ASM < prev    next >
Assembly Source File  |  1987-06-25  |  2KB  |  89 lines

  1. ;    DESC:    Writes character attributes to the screen            V1.00
  2. ;    IN:    *{PAGE} page number (0-3) 4 available pages in 80 column mode
  3. ;        *{ROWCOL} row(0-24),col(0-79) (ie 0345 indicating fourth row,
  4. ;         46th column)
  5. ;        *{ATRB} attribute (see technical reference manual for
  6. ;         information on color graphics adapter)
  7. ;        *{NUM_CHARS} # of chars to be affected
  8. ;    SAMPLE:    Callm    ATRB_WRT,<PAGE,ROWCOL,ATRB,NUM_CHARS>,
  9. ;    ##################################################################
  10.  
  11. ATRB_WRD Segment Para Public 'DATA'
  12. ATRIB        DB    7            ;default color attribute.
  13. PAGEL        DB    0            ;page number (0-3).
  14. LINE        DB    160            ;lnumber of bytes in a
  15.                         ;screen line.
  16. ATRB_WRD Ends
  17.  
  18.     Extrn    PUSHALL:Near            ;save and restore registers.
  19.     Extrn    POPALL:Near
  20.     Extrn    SCRN_TYP:Near            ;determine video memory loc.
  21.  
  22. ATRB_WRC    Segment
  23.     Assume    CS:ATRB_WRC,DS:ATRB_WRD
  24.     Public    ATRB_WRT
  25.  
  26.     Include    CALLM.MAC
  27.  
  28.                         ;notice.
  29.     DB    'ATRB_WRT - V1.00, Copyright 1987, CoreTechs   ',0DH,0AH
  30.  
  31. ATRB_WRT    Proc    Near
  32.     Call    PUSHALL                ;save registers.
  33.  
  34.     Mov    AX,ATRB_WRD            ;setup workarea.
  35.     Mov    DS,AX
  36.  
  37.     Callm    SCRN_TYP,,<BX>            ;determine video memory loc.
  38.  
  39. COLOR:    Mov    AX,4096                ;determine page offset.
  40.     Pop    ES                ;remove args. and replace.
  41.     Pop    SI
  42.     Pop    DI
  43.     Pop    CX
  44.     Push    ES
  45.     Push    SI
  46.     Push    DI
  47.  
  48.     Mov    PAGEL,CL            ;determine offset in memory
  49.     Mul    PAGEL                ;as PAGEL pages of 4096 bytes.
  50.  
  51.     Mov    CL,4                ;divide by 16 to get
  52.     Shr    AX,CL                ;segment value.
  53.  
  54.     Add    BX,AX                ;add to total offset of video
  55.     Mov    ES,BX                ;memory and move to ES.
  56.     
  57.     Pop    AX                ;determine offset of
  58.     Mov    BX,AX                ;row, col on screen.
  59.  
  60.     Xchg    AH,AL                ;xchg row and column.
  61.     Mov    AH,0                ;clear top of AX.
  62.     Mul    LINE                ;compute total offset of rows.
  63.  
  64.     Mov    BH,0                ;compute offset of columns.
  65.     Shl    BX,1
  66.  
  67.     Add    AX,BX                ;add for total offset and
  68.     Mov    DI,AX                ;place in DI.
  69.  
  70.     Pop    AX                ;recover attribute.
  71.     Pop    CX                ;find number of characters
  72.                         ;to apply attribute to.
  73.  
  74.     Mov    ATRIB,AL            ;load attribute from register.
  75.  
  76. CONT:    Mov    SI,OFFSET ATRIB            ;move attribute to affect
  77.     Inc    DI                ;screen string repeatedly
  78.     Cld                    ;until CX is exhausted.
  79.     Movs    ES:BYTE PTR[DI],DS:[SI]    
  80.     Dec    CX
  81.     Jcxz    READY
  82.     Jmp    CONT
  83. READY:    Call    POPALL
  84.     Ret
  85.  
  86. ATRB_WRT    Endp
  87. ATRB_WRC    Ends
  88.     End
  89.